package com.genshang.restaurant.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.genshang.restaurant.entity.Rolelist;
import com.genshang.restaurant.mapper.RolelistMapper;
import com.genshang.restaurant.service.IRolelistService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Alex
 * @since 2020-09-26
 */
@Service
public class RolelistServiceImpl extends ServiceImpl<RolelistMapper, Rolelist> implements IRolelistService {

    @Override
    public Rolelist getRolelistByName(String name) {
        QueryWrapper<Rolelist> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("NAME", name);
        List<Rolelist> rolelistList = this.list(queryWrapper);
        if (CollectionUtils.isEmpty(rolelistList)) {
            return null;
        }
        return rolelistList.get(0);
    }
}
